package com.shenzw.common.aop.anno;

import com.fasterxml.jackson.annotation.JacksonAnnotationsInside;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.shenzw.common.coonstants.DesensitizationTypeEnum;
import com.shenzw.common.serial.DesensitizationSerialize;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

/**
 * 用于脱敏的注解
 *
 * @author shenzw
 * @date 2024/3/4
 */
@Target(ElementType.FIELD)
@Retention(RetentionPolicy.RUNTIME)
@JacksonAnnotationsInside
@JsonSerialize(using = DesensitizationSerialize.class)
public @interface Desensitization {

    /**
     * 脱敏数据类型，在 MY_RULE 的时候, startInclude 和 endExclude 生效
     *
     * @return DesensitizationTypeEnum
     */
    DesensitizationTypeEnum type() default DesensitizationTypeEnum.MY_RULE;

    /**
     * 脱敏开始位置(包含)
     *
     * @return int
     */
    int startInclude() default 0;

    /**
     * 脱敏结束位置(不包含)
     *
     * @return int
     */
    int endExclude() default 0;
}
